package com.supinfo.bonjoursupinfo.fragments;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.supinfo.bonjoursupinfo.R;
import com.supinfo.bonjoursupinfo.database.NewsBDD;
import com.supinfo.bonjoursupinfo.models.News;

public class DetailEventFragment extends Fragment {

	private View view;
	public News myNews;
	public NewsBDD nbdd; 
	
	
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		
		view = inflater.inflate(R.layout.detail_news, container, false);
		int id = Integer.parseInt(this.getArguments().getString("id"));
		nbdd = new NewsBDD();
		myNews = getCurrentNews(id);	
		((TextView) view.findViewById(R.id.detailNewsName)).setText(myNews.getName());
		((TextView) view.findViewById(R.id.detailNewsDescription)).setText(myNews.getDescription());
		return view;
	}
	
	public News getCurrentNews(int id){
		News n = new News();
		nbdd.open();
		n = nbdd.getNewsWithId(id);
		nbdd.close();
		return n;
	}
}
